import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

public class Test7 {
    //查找数组中出现次数超过一般的值
    public static int MoreThanHalfNum_Solution (int[] numbers) {
        // write code here
        int count = 1;
        int num = numbers[0];
        for (int i = 1; i < numbers.length; i++) {
            if(count > 0){
                if(num == numbers[i]){
                    count++;
                }else {
                    count--;
                }
            } else  {
                num = numbers[i];
                count = 1;
            }
        }
        return num;
    }
    public static void main(String[] args) {
        int[]array = {1,9,2,9,9};
        System.out.println(MoreThanHalfNum_Solution(array));
    }
}
